home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3.iso / chapte11 / getlamp / phone.c < prev    next >
C/C++ Source or Header  |  1996-04-28  |  21KB  |  643 lines

  1. #include <windows.h> 
  2. #include <windowsx.h> 
  3. #include "phone.h" 
  4. #include "tapi.h"
  5.  
  6. #define BUFSIZE 256
  7. #define APIHIVERSION     0x00010028    /* 1.40 */
  8. #define APILOWVERSION    0x00010000    /* 1.0 */
  9. #define EXTHIVERSION     0x00010005    /* 1.5 */
  10. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  11. #define MAX_PHONE        2
  12. #define OWNER            0
  13. #define MONITOR        1
  14.  
  15. LPCTSTR lpszAppName = "phoneGetLamp";
  16. LPCTSTR lpszTitle   = "phoneGetLamp"; 
  17.  
  18.  
  19. #if defined (WIN32)
  20.     #define IS_WIN32 TRUE
  21. #else
  22.     #define IS_WIN32 FALSE
  23. #endif
  24.  
  25. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  26. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  27. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  28.  
  29. HINSTANCE hInst;   // current instance
  30. HWND hWnd;         // parent window handle
  31. HWND hListWnd;     // listbox
  32. HDC  hdc;
  33. TEXTMETRIC  tm ;
  34.  
  35. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  36.  
  37.  
  38. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  39.                       LPTSTR lpCmdLine, int nCmdShow)
  40. {
  41.    MSG      msg;
  42.    WNDCLASS wc;
  43.  
  44.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  45.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  46.    wc.cbClsExtra    = 0;                      
  47.    wc.cbWndExtra    = 0;                      
  48.    wc.hInstance     = hInstance;              
  49.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  50.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  51.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  52.    wc.lpszMenuName  = lpszAppName;              
  53.    wc.lpszClassName = lpszAppName;              
  54.  
  55.    if ( IS_WIN95 )
  56.    {
  57.       if ( !RegisterWin95( &wc ) )
  58.          return( FALSE );
  59.    }
  60.    else if ( !RegisterClass( &wc ) )
  61.       return( FALSE );
  62.  
  63.    hInst = hInstance; 
  64.  
  65.    hWnd = CreateWindow( lpszAppName, 
  66.                         lpszTitle,    
  67.                         WS_OVERLAPPEDWINDOW, 
  68.                         CW_USEDEFAULT, 0, 
  69.                         CW_USEDEFAULT, 0,  
  70.                         NULL,              
  71.                         NULL,              
  72.                         hInstance,         
  73.                         NULL               
  74.                       );
  75.  
  76.    if ( !hWnd ) 
  77.       return( FALSE );
  78.  
  79.    ShowWindow( hWnd, nCmdShow ); 
  80.    UpdateWindow( hWnd );         
  81.  
  82.    while( GetMessage( &msg, NULL, 0, 0) )   
  83.    {
  84.       TranslateMessage( &msg ); 
  85.       DispatchMessage( &msg );  
  86.    }
  87.  
  88.    return( msg.wParam ); 
  89. }
  90.  
  91.  
  92. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  93. {
  94.     WNDCLASSEX wcex;
  95.  
  96.    wcex.style         = lpwc->style;
  97.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  98.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  99.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  100.    wcex.hInstance     = lpwc->hInstance;
  101.    wcex.hIcon         = lpwc->hIcon;
  102.    wcex.hCursor       = lpwc->hCursor;
  103.    wcex.hbrBackground = lpwc->hbrBackground;
  104.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  105.    wcex.lpszClassName = lpwc->lpszClassName;
  106.  
  107.    // Added elements for Windows 95.
  108.    //...............................
  109.    wcex.cbSize = sizeof(WNDCLASSEX);
  110.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  111.                             IMAGE_ICON, 16, 16,
  112.                             LR_DEFAULTCOLOR );
  113.             
  114.    return RegisterClassEx( &wcex );
  115. }
  116.  
  117. typedef struct tagMYINFO    // general application information
  118. {
  119.    HPHONEAPP phoneApp;      // instance handle TAPI gives back to us                                                                              through phoneInitialize()
  120.    DWORD dwNumDevices;     // number of available devices
  121.    DWORD dwAPIVersion;     // API version the phone supports
  122.     DWORD dwExtVersion;        // extended version
  123. } MYINFO;
  124.  
  125. typedef struct tagPHONEINFO  // information on an open phone
  126. {
  127.    HPHONE     hPhone;           // handle to the phone as returned by phoneOpen 
  128.     DWORD      dwDeviceID;            // device ID of the phone device
  129.     DWORD        dwRequestID;
  130.     char       szPhoneName[128]; // the phone's name 
  131. }PHONEINFO;
  132.  
  133. MYINFO myInfo;          //instance of MYINFO structure
  134. PHONEINFO myPhoneInfo[MAX_PHONE];  //instance of myPhoneInfo structure
  135.  
  136. LONG lRet;        //return code
  137. char buf[BUFSIZE];    // buffer for debug message
  138. char DataBuf[BUFSIZE]; //get/set data buffer;
  139.  
  140. DWORD i;
  141. DWORD dwHookSwitchDevs;
  142. DWORD dwLampMode;
  143. DWORD dwRingMode;
  144. DWORD dwRingVolume;
  145. DWORD dwHookSwitchVolume;
  146. DWORD dwPhoneStates;
  147. DWORD dwButtonModes;
  148. DWORD dwButtonStates;
  149. DWORD dwGain;
  150. HICON hIcon;
  151.  
  152. LONG lRet;
  153. char buf[BUFSIZE];
  154.  
  155. PHONECAPS*             pPhoneCaps;
  156. PHONEBUTTONINFO*  pButtonInfo;
  157. VARSTRING*            pVarString;
  158. PHONESTATUS*        pPhoneStatus;
  159. PHONEEXTENSIONID    ext_id;                                             
  160.  
  161.  
  162. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  163. {
  164.    switch( uMsg )
  165.    {
  166.       case WM_COMMAND :
  167.          switch( LOWORD( wParam ) )
  168.          {
  169.             case IDM_RUN :
  170.                pPhoneCaps = (PHONECAPS *) calloc (1, sizeof(PHONECAPS)+1000);
  171.                     pPhoneCaps->dwTotalSize = sizeof(PHONECAPS) + 1000;
  172.                    phoneGetDevCaps(myInfo.phoneApp, OWNER, myInfo.dwAPIVersion, myInfo.dwExtVersion, 
  173.                                         pPhoneCaps);
  174.                
  175.                 if (pPhoneCaps->dwNumButtonLamps > 14)
  176.                     {
  177.                         lRet = phoneSetLamp(myPhoneInfo[OWNER].hPhone, pPhoneCaps->dwNumButtonLamps, PHONELAMPMODE_FLUTTER);
  178.                         if (lRet > 0)
  179.                       {
  180.                        myPhoneInfo[OWNER].dwRequestID = lRet;
  181.                       wsprintf(buf, "phoneSetLamp proceeding!");
  182.                             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  183.                       }
  184.                          else 
  185.                       {
  186.                            wsprintf( buf,"phoneSetLamp failed, err=x%lx", lRet);
  187.                           phoneError(lRet);
  188.                            SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  189.                       }    
  190.                     }
  191.                     else
  192.                     {
  193.                         wsprintf( buf,"No additional button/lamp pairs are detectable by TAPI.");
  194.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  195.                       phoneError(lRet);
  196.                         break;
  197.                     }
  198.                 
  199.  
  200.                     lRet = phoneGetLamp(myPhoneInfo[OWNER].hPhone, pPhoneCaps->dwNumButtonLamps, &dwLampMode);
  201.                     if (lRet == 0)
  202.                   {
  203.                    wsprintf(buf, "phoneGetLamp succeeded!");
  204.                        SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  205.                   wsprintf(buf, "The current Lamp Mode for button 13 is x%lx", dwLampMode);
  206.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  207.                   }
  208.                      else 
  209.                   {
  210.                        wsprintf( buf,"phoneGetLampMode failed, err=x%lx", lRet);
  211.                       phoneError(lRet);
  212.                   }    
  213.                 
  214.                free (pPhoneCaps);
  215.                break;
  216.  
  217.             case IDM_EXIT :
  218.                for (i = 0; i < myInfo.dwNumDevices; i++)
  219.                     phoneClose(myPhoneInfo[i].hPhone);
  220.                 
  221.                    phoneShutdown(myInfo.phoneApp);
  222.                DestroyWindow( hWnd );
  223.                break;
  224.             
  225.             case IDM_ABOUT :
  226.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  227.                break;
  228.          }
  229.                 
  230.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  231.  
  232.       
  233.        case WM_CREATE :
  234.  
  235.           hdc = GetDC (hWnd) ;
  236.           GetTextMetrics (hdc, &tm) ;
  237.           ReleaseDC (hWnd, hdc) ;
  238.  
  239.           hListWnd = CreateWindowEx( 0, "listbox", 
  240.                         " ",    
  241.                         WS_CHILD | WS_VISIBLE,  
  242.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  243.                         tm.tmAveCharWidth * 16 +
  244.                                    GetSystemMetrics (SM_CXVSCROLL), 
  245.                         tm.tmHeight * 5,  
  246.                         hWnd,              
  247.                         NULL,              
  248.                         hInst,         
  249.                         NULL               
  250.                         );
  251.       
  252.              //phoneInitialize
  253.                //...............................................
  254.             lRet = phoneInitialize(&myInfo.phoneApp, hInst, phoneCallback, lpszAppName, &myInfo.dwNumDevices);
  255.             if (lRet == 0) 
  256.             {
  257.                 
  258.                wsprintf(buf, "phoneInitialize succeeded!");
  259.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  260.             }
  261.                
  262.                else 
  263.                {
  264.                    wsprintf( buf,"phoneInitialize failed, err=x%lx",lRet);
  265.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  266.                     phoneError(lRet);
  267.                     break;
  268.             }                    
  269.                
  270.             //phoneNegotiateAPIVersion
  271.                   //...............................................
  272.             lRet = phoneNegotiateAPIVersion(myInfo.phoneApp, 0, APILOWVERSION, APIHIVERSION, 
  273.                                                     &myInfo.dwAPIVersion, &ext_id);
  274.             if (lRet == 0)                        
  275.             {
  276.                wsprintf(buf, "phoneNegotiateAPIVersion succeeded!");
  277.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  278.             }
  279.                   else 
  280.                   {
  281.                    wsprintf(buf, "phoneNegotiateAPIVersion failed, err=x%lx", lRet);
  282.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  283.                     phoneError(lRet);
  284.                     phoneShutdown(myInfo.phoneApp);
  285.                break;
  286.              }
  287.  
  288.                //phoneNegotiateExtVersion
  289.                //...............................................
  290.             lRet = phoneNegotiateExtVersion(myInfo.phoneApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  291.                                                 EXTHIVERSION, &myInfo.dwExtVersion);
  292.             if (lRet == 0)                        
  293.             {
  294.                     wsprintf(buf, "phoneNegotiateExtVersion succeeded!");
  295.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  296.               }
  297.                   else 
  298.                {
  299.                     wsprintf(buf, "phoneNegotiateExtVersion failed, err=x%lx", lRet);
  300.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  301.                       phoneError(lRet);
  302.                }
  303.  
  304.             //phoneOpen
  305.                //................................................................
  306.                for (i = 0; i < myInfo.dwNumDevices; i++)
  307.                {
  308.                    if ( i == 0)
  309.                        lRet = phoneOpen(myInfo.phoneApp,i,&myPhoneInfo[i].hPhone,
  310.                                  myInfo.dwAPIVersion,0,(DWORD)phoneCallback, PHONEPRIVILEGE_OWNER);
  311.                    else
  312.                        lRet = phoneOpen(myInfo.phoneApp,i,&myPhoneInfo[i].hPhone,
  313.                                  myInfo.dwAPIVersion,0,(DWORD)phoneCallback, PHONEPRIVILEGE_MONITOR);
  314.                    
  315.                    if (lRet == 0)
  316.                    {
  317.                      wsprintf(buf, "phoneOpen succeeded!");
  318.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  319.                   pPhoneCaps = (PHONECAPS *) calloc (1, sizeof(PHONECAPS)+1000);
  320.                       pPhoneCaps->dwTotalSize = sizeof(PHONECAPS) + 1000;
  321.                          
  322.                       phoneGetDevCaps(myInfo.phoneApp,i,
  323.                       myInfo.dwAPIVersion, myInfo.dwExtVersion, pPhoneCaps);
  324.                       strcpy(buf, ((LPSTR)(pPhoneCaps)+pPhoneCaps->dwProviderInfoOffset));
  325.                   strcat( buf, " is the phone providor's name." );
  326.                   SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  327.                   strcpy(buf, ((LPSTR)(pPhoneCaps)+pPhoneCaps->dwPhoneNameOffset));
  328.                      
  329.                   if (i == 0)
  330.                   {
  331.                      strcat( buf, " is the phone's name opened with OWNER privilege." );
  332.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  333.                   }
  334.                   else
  335.                   {
  336.                      strcat( buf, " is the phone's name opened with MONITOR privilege." );
  337.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  338.                   }
  339.                }
  340.                    else 
  341.                    {
  342.                        wsprintf( buf,"phoneOpen failed, err=x%lx", lRet);
  343.                        phoneError(lRet);
  344.                       break;
  345.                }
  346.                   } 
  347.  
  348.             break;
  349.       
  350.       case WM_SIZE:
  351.           MoveWindow(hListWnd, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  352.          break;
  353.  
  354.       case WM_DESTROY :
  355.          PostQuitMessage(0);
  356.          break;
  357.             
  358.       default :
  359.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  360.    }
  361.  
  362.    return( 0L );
  363. }
  364.  
  365.  
  366.  
  367. /****************************************************************************
  368.     FUNCTION: phoneCallback
  369.     PURPOSE:  callback function handles phone events
  370. ****************************************************************************/
  371. LRESULT CALLBACK phoneCallback (DWORD  dwDevice, DWORD dwMsg,
  372.                                 DWORD dwCallbackInst, DWORD dwParam1,
  373.                                 DWORD dwParam2,DWORD dwParam3)
  374. {
  375.     
  376.     switch (dwMsg)
  377.     {
  378.         case PHONE_REPLY:
  379.             if (dwParam1 == myPhoneInfo[OWNER].dwRequestID) 
  380.                    if (dwParam2 != 0)
  381.                 {
  382.                        wsprintf( buf,"Function failed, err=x%lx", lRet);
  383.                        phoneError(lRet);
  384.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  385.                    }
  386.             break;       
  387.  
  388.         case PHONE_STATE:
  389.         
  390.             if (dwParam1 == PHONESTATE_RINGMODE)
  391.             {
  392.                 lRet = phoneGetRing(myPhoneInfo[OWNER].hPhone, &dwRingMode, &dwRingVolume);
  393.                 if (lRet == 0)
  394.                {
  395.                 wsprintf(buf, "phoneGetRing succeeded!");
  396.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  397.                if (dwRingMode == 0)
  398.                     {
  399.                         wsprintf(buf, "The phone device is currently not ringing.");
  400.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  401.                }
  402.                     else
  403.                     {
  404.                         wsprintf(buf, "The phone is ringing with a Ring Mode pattern of x%lx", dwRingMode);
  405.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  406.                    wsprintf(buf, "The phnes's Ring Volume is x%lx", dwRingVolume);
  407.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  408.                     }
  409.                }
  410.                  else 
  411.                {
  412.                     wsprintf( buf,"phoneGetRing failed, err=x%lx", lRet);
  413.                    phoneError(lRet);
  414.                }        
  415.               
  416.               break;
  417.               }
  418.             
  419.  
  420.             if (dwParam1 == PHONESTATE_SPEAKERHOOKSWITCH)
  421.             {   
  422.                 lRet = phoneGetHookSwitch(myPhoneInfo[OWNER].hPhone, &dwHookSwitchDevs);
  423.                 if (lRet == 0)
  424.                {
  425.                wsprintf(buf, "phoneGetHookSwitch succeeded!");
  426.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  427.                
  428.                if (dwHookSwitchDevs & PHONEHOOKSWITCHDEV_SPEAKER)
  429.                     {
  430.                         wsprintf(buf, "The phone's HookSwitch Speaker is offhook!");
  431.                        SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  432.                     }
  433.                     else
  434.                     {
  435.                    wsprintf(buf, "The phone's HookSwitch Speaker is onhook!");
  436.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  437.                     }
  438.  
  439.               }
  440.                  else 
  441.                {
  442.                       wsprintf( buf,"phoneGetHookSwitch failed, err=x%lx", lRet);
  443.                    phoneError(lRet);
  444.                }    
  445.             break;                
  446.             }
  447.  
  448.             if (dwParam1 == PHONESTATE_SPEAKERVOLUME)
  449.             {   
  450.                 lRet = phoneGetVolume(myPhoneInfo[OWNER].hPhone, PHONEHOOKSWITCHDEV_SPEAKER, &dwHookSwitchVolume);
  451.                if (lRet == 0)
  452.                {
  453.                 wsprintf(buf, "phoneGetVolume succeeded!");
  454.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  455.                wsprintf(buf, "The current volume for the Speaker Hookswitch is x%lx", dwHookSwitchVolume);
  456.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  457.                }
  458.                  else 
  459.                {
  460.                     wsprintf( buf,"phoneGetVolume failed, err=x%lx", lRet);
  461.                    phoneError(lRet);
  462.                }    
  463.             break;                
  464.             }
  465.  
  466.             if (dwParam1 == PHONESTATE_SPEAKERGAIN)
  467.             {   
  468.                 lRet = phoneGetGain(myPhoneInfo[OWNER].hPhone, PHONEHOOKSWITCHDEV_SPEAKER, &dwGain);
  469.                 if (lRet == 0)
  470.                {
  471.                   wsprintf(buf, "phoneGetGain succeeded!");
  472.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  473.                     wsprintf(buf, "The current Gain is x%lx", dwGain);
  474.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  475.                }
  476.                  else 
  477.                {
  478.                       wsprintf( buf,"phoneGetGain failed, err=x%lx", lRet);
  479.                     phoneError(lRet);
  480.                }
  481.             break;                
  482.             }
  483.             
  484.             if (dwParam1 == PHONESTATE_DISPLAY)
  485.             {   
  486.                 pVarString = (VARSTRING *) calloc (1, sizeof(VARSTRING)+1000);
  487.                 pVarString->dwTotalSize = sizeof(VARSTRING) + 1000;
  488.                 lRet = phoneGetDisplay(myPhoneInfo[OWNER].hPhone, pVarString);
  489.                 if (lRet == 0)
  490.                {
  491.                   wsprintf(buf, "phoneGetDisplay succeeded!");
  492.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  493.                strcpy(buf, lpszTitle);
  494.                //strcpy(buf, ((LPSTR)(pVarString)+pVarString->dwStringOffset));
  495.                strcat( buf, " is the current phone display." );
  496.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  497.                }
  498.                  else 
  499.                {
  500.                    wsprintf( buf,"phoneGetDisplay failed, err=x%lx", lRet);
  501.                   phoneError(lRet);
  502.                }    
  503.                     
  504.                 free (pVarString);
  505.                 break;
  506.               }
  507.    }
  508.    return (TRUE);
  509.  
  510.  
  511. /****************************************************************************
  512.     FUNCTION: phoneError
  513.     PURPOSE:  phone error messages
  514. ****************************************************************************/
  515. void phoneError (LONG lrc)
  516. {
  517.  switch (lrc) {
  518.     case PHONEERR_INVALAPPHANDLE:
  519.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  520.        break;
  521.     case PHONEERR_BADDEVICEID:
  522.        MessageBox (hWnd,"The specified phone device ID is out of range.", "", 
  523.                    MB_OK);
  524.        break;
  525.     case PHONEERR_INCOMPATIBLEAPIVERSION:
  526.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  527.        break;
  528.     
  529.     case PHONEERR_INVALBUTTONLAMPID:
  530.        MessageBox (hWnd, "Invalid Button Lamp ID.", "", MB_OK);
  531.        break;
  532.  
  533.     case PHONEERR_INVALBUTTONMODE:
  534.        MessageBox (hWnd, "Invalid Button Mode.", "", MB_OK);
  535.        break;
  536.  
  537.     case PHONEERR_INVALBUTTONSTATE:
  538.        MessageBox (hWnd, "Invalid Button State", "", MB_OK);
  539.        break;
  540.  
  541.     case PHONEERR_INUSE:
  542.        MessageBox (hWnd, "Phone in Use.", "", MB_OK);
  543.        break;
  544.     
  545.     case PHONEERR_INVALHOOKSWITCHDEV:
  546.        MessageBox (hWnd, "Invalid Hookswitch Device.", "", MB_OK);
  547.        break;
  548.  
  549.     case PHONEERR_INVALHOOKSWITCHMODE:
  550.        MessageBox (hWnd, "Invalid Hookswitch Device Mode.", "", MB_OK);
  551.        break;
  552.  
  553.     case PHONEERR_INVALLAMPMODE:
  554.        MessageBox (hWnd, "Invalid Lamp Mode.", "", MB_OK);
  555.        break;
  556.      
  557.     case PHONEERR_INCOMPATIBLEEXTVERSION:
  558.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  559.        break;
  560.     case PHONEERR_NOMEM:
  561.        MessageBox (hWnd, "No memory","", MB_OK);
  562.        break;
  563.     case PHONEERR_NODRIVER:
  564.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  565.        break;
  566.     case PHONEERR_RESOURCEUNAVAIL:
  567.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  568.        break;
  569.     case PHONEERR_ALLOCATED:
  570.        MessageBox (hWnd, "Allocation error", "", MB_OK);
  571.        break;
  572.     case PHONEERR_INVALDATAID:
  573.        MessageBox (hWnd, "The data ID is out of range.", "", MB_OK);
  574.        break;
  575.     case PHONEERR_INVALDEVICECLASS:
  576.        MessageBox (hWnd, "The device class was invalid.", "", MB_OK);
  577.        break;
  578.     case PHONEERR_INVALPOINTER:
  579.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  580.                    "", MB_OK);
  581.        break;
  582.     case PHONEERR_OPERATIONFAILED:
  583.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  584.        break;
  585.     case PHONEERR_INVALPHONEHANDLE:
  586.        MessageBox (hWnd, "Invalid phone handle", "", MB_OK);
  587.        break;
  588.     case PHONEERR_INVALPHONESTATE :
  589.        MessageBox (hWnd, "Invalid call state for this function.", "", MB_OK);
  590.        break;
  591.     case PHONEERR_INVALPRIVILEGE:
  592.        MessageBox (hWnd, "Invalid privilege for this function.", "", MB_OK);
  593.        break;
  594.     case PHONEERR_NODEVICE:
  595.        MessageBox (hWnd, "No associated device for given class",
  596.                    "", MB_OK);
  597.        break;
  598.     case PHONEERR_OPERATIONUNAVAIL:
  599.        MessageBox (hWnd, "The operation is unavailable",
  600.                    "", MB_OK);
  601.        break;
  602.     case PHONEERR_INVALPARAM:
  603.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  604.        break; 
  605.  
  606.     case PHONEERR_INVALRINGMODE:
  607.             MessageBox(hWnd, "Invalid Ring Mode", "", MB_OK);
  608.        break; 
  609.  
  610.     }
  611.     
  612.              
  613. }
  614.  
  615. LRESULT CALLBACK About( HWND hDlg,           
  616.                         UINT message,        
  617.                         WPARAM wParam,       
  618.                         LPARAM lParam)
  619. {
  620.    switch (message) 
  621.    {
  622.        case WM_INITDIALOG: 
  623.                return (TRUE);
  624.  
  625.        case WM_COMMAND:                              
  626.                if (   LOWORD(wParam) == IDOK         
  627.                    || LOWORD(wParam) == IDCANCEL)    
  628.                {
  629.                        EndDialog(hDlg, TRUE);        
  630.                        return (TRUE);
  631.                }
  632.                break;
  633.    }
  634.  
  635.    return (FALSE); 
  636. }
  637.  
  638.  
  639.  
  640.  
  641.  
  642.